package org.hegang.design.first.adapterpattern;

import org.hegang.design.first.adapterpattern.impl.Mp4Player;
import org.hegang.design.first.adapterpattern.impl.VlcPlayer;

/**
 * @ClassName MediaAdapter
 * @Describe: 适配器
 * @Author: gang.he
 * @Email: SmileSkylife@outlook.com
 * @Date: Created in 22:59 2019/7/22
 * @Modified_By: TODO
 * @Version: V1.0
 */
public class MediaAdapter implements MediaPlayer{
    private AdvancedMediaPlayer advancedMediaPlayer;


    /**
     * 根据传入的参数适配
     * @param audioType
     */
    public MediaAdapter(String audioType){
        if (audioType.trim().equalsIgnoreCase("vlc")){
            advancedMediaPlayer = new VlcPlayer();
        }else if (audioType.trim().equalsIgnoreCase("mp4")){
            advancedMediaPlayer = new Mp4Player();
        }
    }
    @Override
    public void play(String audioType, String fileName) {
        if (audioType.trim().equalsIgnoreCase("vlc")){
            advancedMediaPlayer.playVlc(fileName);
        }else if (audioType.trim().equalsIgnoreCase("mp4")){
            advancedMediaPlayer.playMp4(fileName);
        }
    }
}
